#ifndef VERTEXENTITY_H
#define VERTEXENTITY_H

#include "Common/Common.h"
#include "EditorCore/IProvider.h"
#include "EditorCore/Entity.h"

class PolygonEntity;

class VertexEntity : public editor_core::Entity, public editor_core::IProvider<VertexEntity*>
{
public:
	VertexEntity( PolygonEntity* parentPolygon, const cmn::Vec2& position );
	virtual ~VertexEntity();

	inline cmn::Vec2 GetAbsolutePosition() const;
	inline void SetAbsolutePosition( const cmn::Vec2& position );

	inline cmn::Vec2 GetPosition() const { return m_position; }
	inline void SetPosition( cmn::Vec2 position ) { m_position = position; }

	PolygonEntity* GetParentPolygon() const { return m_parentPolygon; }

	virtual inline VertexEntity* GetEntity() { return this; }

	virtual void Tick();

	virtual cmn::Vec2 Move( const cmn::Vec2& vector );

	virtual void Delete();
	virtual void Undelete();

	virtual bool Contains( const cmn::Vec2& point ) const;

	virtual void GetChildren( cmn::ICollection<IEntity*>& children ) const;
	virtual void GetParents( cmn::ICollection<IEntity*>& parents ) const;

	virtual void GetProperties( cmn::ICollection<editor_core::Property>& properties ) const;
	virtual bool TryUpdateProperty( editor_core::Property& property ) const;
	virtual bool TryUpdateFromProperty( const editor_core::Property& property );

	inline static float GetRadius() { return 0.1f; }

protected:
	virtual void DrawInner( drawing::IDrawer* drawer );

private:
	cmn::Vec2 m_position;

	PolygonEntity* m_parentPolygon;
};

#endif
